package com.xgpro.mapper.talentintroduction;

import com.xgpro.domain.talentintroduction.entity.IntroduceJob;
import com.xgpro.domain.talentintroduction.vo.IntroducePC;
import com.xgpro.domain.talentintroduction.vo.RecruitmentBackPC;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author tx
 * @version 1.0
 * @date 2019/8/23 21:36
 */
public interface IntroduceJobMapper extends Mapper<IntroduceJob> {
    /**
     * 查询符合条件的应聘信息
     * @param ids
     * @return
     */
    @Select("<script>" +
            " select t_introduce_job.id as id,t_introduce_job.name as username,t_recruitment.kind as kind,t_recruitment.name as jobName,t_introduce_job.time as time,t_user.username as introduceUser,t_introduce_job.attachment_address as attachmentAddress from" +
            " t_introduce_job left join t_user on t_introduce_job.introduce_user_id=t_user.id left join t_recruitment on t_recruitment.id=t_introduce_job.recruitment_id " +
            " <where>"+
            " t_introduce_job.recruitment_id in " +
            "<foreach collection='list' index='index' item='id'  open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "   and t_introduce_job.ref!=1" +
            " </where>" +
            " group by time DESC" +
            "</script>")
    List<RecruitmentBackPC> qryRecruitmentPC(List<Integer> ids);

    @Select("<script>" +
            " select t_introduce_job.id as id,t_introduce_job.name as username,t_recruitment.kind as kind,t_recruitment.name as jobName,t_introduce_job.time as time,t_user.username as introduceUser,t_introduce_job.attachment_address as attachmentAddress from" +
            " t_introduce_job left join t_user on t_introduce_job.introduce_user_id=t_user.id left join t_recruitment on t_recruitment.id=t_introduce_job.recruitment_id " +
            " <where>"+
            " t_introduce_job.name like CONCAT('%',#{introduceName},'%') and t_introduce_job.recruitment_id in " +
            "<foreach collection='list' index='index' item='id'  open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "   and t_introduce_job.ref!=1" +
            " </where>" +
            " group by time DESC" +
            "</script>")
    List<RecruitmentBackPC> qryRecruitmentPC2(@Param("list") List<Integer> ids,@Param("introduceName") String introduceName);


    /**
     * 查询应聘信息详情
     * @param id
     * @return
     */
    @Select("select t_introduce_job.id as id,t_introduce_job.name as username,t_user.phone as phone,t_introduce_job.edu as edu,t_introduce_job.job_time as jobTime,t_recruitment.name as jobName,t_introduce_job.attachment_address as attachmentAddress from" +
            " t_introduce_job left join t_user on t_introduce_job.introduce_user_id=t_user.id left join t_recruitment on t_recruitment.id=t_introduce_job.recruitment_id " +
            " where t_introduce_job.id=#{id} and t_introduce_job.ref <> 1")
    IntroducePC qryIntroducePcById(Integer id);

    /**
     * 应聘信息批量删除
     * @param ids
     * @return
     */
    @Update("<script>" +
            " update t_introduce_job set ref=1 " +
            " <where>"+
            " id in " +
            " <foreach collection='list' index='index' item='id'  open='(' separator=',' close=')'>" +
            " #{id}" +
            " </foreach>" +
            " </where>" +
            "</script>")
    Integer deleteIntroduceByList(List<Integer> ids);
}
